<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/2/25
 * Time: 11:41
 */
namespace app\modules\api\models\beauty_cook;
use app\models\ContentWork;
use app\modules\api\models\Model;

/**
 * @property ContentWork $model
 * @property $content_id
 * @property $image
 * @property $discription
 */
class ContentWorkForm extends Model{
    public $content_id;
    public $image;
    public $discription;
    public $model;
    public function rules(){
        return [
            [['content_id'],'required'],
            [['image','discription'],'string']
        ];
    }
    public function save(){
        if (!$this->validate()) {
            return $this->getModelError();
        }
        $this->model->content_id = $this->content_id;
        $this->model->image = $this->image;
        $this->model->discription = $this->discription;
        if($this->model->save()) {
            return [
                'code' => 0,
                'msg' => '保存成功',
            ];
        }
        else
            return $this->getModelError($this->model);

    }
}